package com.briup.logging.config;

import com.briup.logging.persist.ILoggingAccessPersisting;
import com.briup.logging.persist.impl.DefaultLoggingAccessPersistingImpl;
import com.briup.logging.resolver.LoggingAccessAspectResolver;
import com.briup.logging.resolver.LoggingDetailHandler;
import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置类-日志模块
 */
@ConditionalOnBean({LoggingDetailHandler.class})
@Configuration
@Data
public class LoggingAutoConfiguration {

	@Bean
	public LoggingAccessAspectResolver loggingAccessAspectResolver(ILoggingAccessPersisting loggingAccessPersisting) {
		return new LoggingAccessAspectResolver(loggingAccessPersisting);
	}


    @Bean
    @ConditionalOnMissingBean(ILoggingAccessPersisting.class)
    public ILoggingAccessPersisting loggingAccessPersisting() {
        return new DefaultLoggingAccessPersistingImpl();
    }

}